package com.dove.feign;

import com.dove.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class DeptFeignServiceFactory implements FallbackFactory {
    @Override
    public Object create(Throwable throwable) {
        return new DeptFeignService() {
            @Override
            public boolean add(Dept dept) {
                return false;
            }

            @Override
            public Dept get(Long id) {
                return new Dept()
                        .setDeptno(id)
                        .setDname("服务器紧张,服务降级")
                        .setDb_source("from hystrix");
            }

            @Override
            public List<Dept> queryAll() {
                return null;
            }
        };
    }
}
